package alarm;

import org.snmp4j.smi.Integer32;

public enum SampleType {
	absoluteValue("Assoluto"), 
	deltaValue("Delta");
	
	private String description = null;
	
	private SampleType(String description) {
		this.description = description;
	}

	public int getValue() {
		switch (this) {
		case absoluteValue:
			return 1;
		case deltaValue:
			return 2;
		default:
			return 1;
		}
	}

	@Override
	public String toString() {
		return description;
	}

	public static SampleType fromString(final String value) {
		if (value.equals(deltaValue.toString()))
			return deltaValue;
		else if (value.equals(absoluteValue.toString()))
			return absoluteValue;
		else
			return deltaValue;
	}

	public Integer32 toVariable() {
		return new Integer32(getValue());
	}

	public static SampleType fromVariable(Integer32 variable) {
		switch (variable.getValue()) {
		case 1:
		default:
			return absoluteValue;
		case 2:
			return deltaValue;
		}
	}
}